package org.jeecg.modules.knowledgeType.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;

/**
 * TODO:
 *
 * @author Zhang Hao yu
 * @date 2020/11/12 14:00
 */
@Data
public class KnowledgeColumnVO implements Serializable {

    /**
     * id
     */
    @TableId(type = IdType.ID_WORKER_STR)
    private String id;

    /**
     * 字典id
     */
    private String dictId;

    /**
     * 字典项文本
     */
    @Excel(name = "字典项文本", width = 20)
    private String itemText;

    /**
     * 字典项值
     */
    @Excel(name = "字典项值", width = 30)
    private String itemValue;

    /**图片*/
    @Excel(name = "图片", width = 15)
    private transient String columnImageString;

    private byte[] columnImage;

    public byte[] getColumnImage(){
        if(columnImageString==null){
            return null;
        }
        try {
            return columnImageString.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }

    public String getcolumnImageString(){
        if(columnImage==null || columnImage.length==0){
            return "";
        }
        try {
            return new String(columnImage,"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return "";
    }
}